<!DOCTYPE html>


<html lang="zh-CN">
  

    <head>
      <meta charset="utf-8" />
        
      <meta
        name="viewport"
        content="width=device-width, initial-scale=1, maximum-scale=1"
      />
      <title>mysql数据库 |  hangfei&#39;blog</title>
  <meta name="generator" content="hexo-theme-ayer">
      
      <link rel="shortcut icon" href="/favicon.ico" />
       
<link rel="stylesheet" href="/dist/main.css">

      <link
        rel="stylesheet"
        href="https://cdn.jsdelivr.net/gh/Shen-Yu/cdn/css/remixicon.min.css"
      />
      
<link rel="stylesheet" href="/css/custom.css">
 
      <script src="https://cdn.jsdelivr.net/npm/pace-js@1.0.2/pace.min.js"></script>
       
 

      <link
        rel="stylesheet"
        href="https://cdn.jsdelivr.net/npm/@sweetalert2/theme-bulma@5.0.1/bulma.min.css"
      />
      <script src="https://cdn.jsdelivr.net/npm/sweetalert2@11.0.19/dist/sweetalert2.min.js"></script>

      <!-- mermaid -->
      
      <script src="https://cdn.jsdelivr.net/npm/mermaid@8.9.2/dist/mermaid.min.js"></script>
      
      <style>
        .swal2-styled.swal2-confirm {
          font-size: 1.6rem;
        }
      </style>
    </head>
  </html>
</html>


<body>
  <div id="app">
    
      
    <main class="content on">
      <section class="outer">
  <article
  id="post-mysql数据库"
  class="article article-type-post"
  itemscope
  itemprop="blogPost"
  data-scroll-reveal
>
  <div class="article-inner">
    
    <header class="article-header">
       
<h1 class="article-title sea-center" style="border-left:0" itemprop="name">
  mysql数据库
</h1>
 

      
    </header>
     
    <div class="article-meta">
      <a href="/2022/03/06/mysql%E6%95%B0%E6%8D%AE%E5%BA%93/" class="article-date">
  <time datetime="2022-03-06T14:45:16.306Z" itemprop="datePublished">2022-03-06</time>
</a>   
<div class="word_count">
    <span class="post-time">
        <span class="post-meta-item-icon">
            <i class="ri-quill-pen-line"></i>
            <span class="post-meta-item-text"> 字数统计:</span>
            <span class="post-count">1.6k</span>
        </span>
    </span>

    <span class="post-time">
        &nbsp; | &nbsp;
        <span class="post-meta-item-icon">
            <i class="ri-book-open-line"></i>
            <span class="post-meta-item-text"> 阅读时长≈</span>
            <span class="post-count">7 分钟</span>
        </span>
    </span>
</div>
 
    </div>
      
    <div class="tocbot"></div>




  
    <div class="article-entry" itemprop="articleBody">
       
  <h1 id="mysql数据库"><a href="#mysql数据库" class="headerlink" title="mysql数据库"></a>mysql数据库</h1><h2 id="1、对数据库的操作"><a href="#1、对数据库的操作" class="headerlink" title="1、对数据库的操作"></a>1、对数据库的操作</h2><h3 id="1-1、创建数据库"><a href="#1-1、创建数据库" class="headerlink" title="1.1、创建数据库"></a>1.1、创建数据库</h3><pre class="line-numbers language-sql" data-language="sql"><code class="language-sql"><span class="token keyword">CREATE</span> <span class="token keyword">DATABASE</span> <span class="token keyword">database</span><span class="token operator">-</span>name<span aria-hidden="true" class="line-numbers-rows"><span></span></span></code></pre>



<h3 id="1-2、删除数据库"><a href="#1-2、删除数据库" class="headerlink" title="1.2、删除数据库"></a>1.2、删除数据库</h3><pre class="line-numbers language-sql" data-language="sql"><code class="language-sql"><span class="token keyword">DROP</span> <span class="token keyword">DATABASE</span> <span class="token keyword">database</span><span class="token operator">-</span>name<span aria-hidden="true" class="line-numbers-rows"><span></span></span></code></pre>

<h2 id="2、对表的操作"><a href="#2、对表的操作" class="headerlink" title="2、对表的操作"></a>2、对表的操作</h2><h3 id="2-1、单表操作"><a href="#2-1、单表操作" class="headerlink" title="2.1、单表操作"></a>2.1、单表操作</h3><ul>
<li><p>建表</p>
<pre class="line-numbers language-sql" data-language="sql"><code class="language-sql"><span class="token keyword">create</span> <span class="token keyword">table</span> users<span class="token punctuation">(</span>
  id <span class="token keyword">int</span><span class="token punctuation">(</span><span class="token number">10</span><span class="token punctuation">)</span> <span class="token operator">not</span> <span class="token boolean">null</span> <span class="token keyword">primary</span> <span class="token keyword">key</span><span class="token punctuation">,</span>
  name <span class="token keyword">varchar</span><span class="token punctuation">(</span><span class="token number">255</span><span class="token punctuation">)</span> <span class="token operator">not</span> <span class="token boolean">null</span><span class="token punctuation">,</span>
  pwd <span class="token keyword">varchar</span><span class="token punctuation">(</span><span class="token number">255</span><span class="token punctuation">)</span> <span class="token operator">not</span> <span class="token boolean">null</span>
<span class="token punctuation">)</span><span class="token punctuation">;</span><span aria-hidden="true" class="line-numbers-rows"><span></span><span></span><span></span><span></span><span></span></span></code></pre></li>
<li><p>插入数据</p>
<pre class="line-numbers language-sql" data-language="sql"><code class="language-sql"><span class="token keyword">insert</span> <span class="token keyword">into</span> users <span class="token keyword">values</span><span class="token punctuation">(</span><span class="token number">1</span>，<span class="token string">'张三'</span>，<span class="token string">'123456'</span><span class="token punctuation">)</span><span class="token punctuation">,</span><span class="token punctuation">(</span><span class="token number">2</span><span class="token punctuation">,</span><span class="token string">'李四'</span><span class="token punctuation">,</span><span class="token string">'123456'</span><span class="token punctuation">)</span><span aria-hidden="true" class="line-numbers-rows"><span></span></span></code></pre></li>
<li><p>在表中添加字段</p>
<pre class="line-numbers language-sql" data-language="sql"><code class="language-sql"><span class="token keyword">alter</span> <span class="token keyword">table</span> student <span class="token keyword">add</span> <span class="token keyword">column</span> phone <span class="token keyword">varchar</span><span class="token punctuation">(</span><span class="token number">11</span><span class="token punctuation">)</span> <span class="token operator">not</span> <span class="token boolean">null</span> <span class="token keyword">comment</span><span class="token string">'电话号码'</span><span class="token punctuation">;</span><span aria-hidden="true" class="line-numbers-rows"><span></span></span></code></pre></li>
<li><p>添加字段内的值</p>
<pre class="line-numbers language-sql" data-language="sql"><code class="language-sql"><span class="token keyword">update</span> student <span class="token keyword">set</span> phone<span class="token operator">=</span><span class="token string">'13121312131'</span> <span class="token keyword">where</span> id<span class="token operator">=</span><span class="token number">1</span><span class="token punctuation">;</span><span aria-hidden="true" class="line-numbers-rows"><span></span></span></code></pre>

<p>​</p>
</li>
<li><p>修改中文列的编码格式</p>
<pre class="line-numbers language-sql" data-language="sql"><code class="language-sql"><span class="token comment">//修改单项</span>
<span class="token keyword">ALTER</span> <span class="token keyword">TABLE</span> users CHANGE name name <span class="token keyword">VARCHAR</span><span class="token punctuation">(</span><span class="token number">255</span><span class="token punctuation">)</span> <span class="token keyword">CHARACTER</span> <span class="token keyword">SET</span> utf8<span class="token punctuation">;</span>
<span class="token keyword">ALTER</span> <span class="token keyword">TABLE</span> users CHANGE pwd pwd <span class="token keyword">VARCHAR</span><span class="token punctuation">(</span><span class="token number">255</span><span class="token punctuation">)</span> <span class="token keyword">CHARACTER</span> <span class="token keyword">SET</span> utf8<span class="token punctuation">;</span>
<span class="token comment">//修改数据库的编码格式</span>
<span class="token keyword">ALTER</span> <span class="token keyword">DATABASE</span> mybatis <span class="token keyword">CHARACTER</span> <span class="token keyword">SET</span><span class="token operator">=</span>utf8<span class="token punctuation">;</span><span aria-hidden="true" class="line-numbers-rows"><span></span><span></span><span></span><span></span><span></span></span></code></pre></li>
<li><p>检索字段名并升序排列</p>
<pre class="line-numbers language-sql" data-language="sql"><code class="language-sql">mysql<span class="token operator">></span> <span class="token keyword">select</span> name <span class="token punctuation">,</span>age <span class="token keyword">from</span> student <span class="token keyword">order</span> <span class="token keyword">by</span> age<span class="token punctuation">;</span>
<span class="token operator">+</span><span class="token comment">------+-----+</span>
<span class="token operator">|</span> name <span class="token operator">|</span> age <span class="token operator">|</span>
<span class="token operator">+</span><span class="token comment">------+-----+</span>
<span class="token operator">|</span> 张飞 <span class="token operator">|</span> <span class="token number">18</span>  <span class="token operator">|</span>
<span class="token operator">|</span> 关羽 <span class="token operator">|</span> <span class="token number">21</span>  <span class="token operator">|</span>
<span class="token operator">+</span><span class="token comment">------+-----+</span>
<span class="token number">2</span> <span class="token keyword">rows</span> <span class="token operator">in</span> <span class="token keyword">set</span> <span class="token punctuation">(</span><span class="token number">0.00</span> sec<span class="token punctuation">)</span><span aria-hidden="true" class="line-numbers-rows"><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span></span></code></pre></li>
<li><p>检索字段名并按降序排列</p>
<pre class="line-numbers language-sql" data-language="sql"><code class="language-sql">mysql<span class="token operator">></span> <span class="token keyword">select</span> name <span class="token punctuation">,</span>age <span class="token keyword">from</span> student <span class="token keyword">order</span> <span class="token keyword">by</span> age <span class="token keyword">desc</span><span class="token punctuation">;</span>
<span class="token operator">+</span><span class="token comment">------+-----+</span>
<span class="token operator">|</span> name <span class="token operator">|</span> age <span class="token operator">|</span>
<span class="token operator">+</span><span class="token comment">------+-----+</span>
<span class="token operator">|</span> 关羽 <span class="token operator">|</span> <span class="token number">21</span>  <span class="token operator">|</span>
<span class="token operator">|</span> 张飞 <span class="token operator">|</span> <span class="token number">18</span>  <span class="token operator">|</span>
<span class="token operator">+</span><span class="token comment">------+-----+</span>
<span class="token number">2</span> <span class="token keyword">rows</span> <span class="token operator">in</span> <span class="token keyword">set</span> <span class="token punctuation">(</span><span class="token number">0.00</span> sec<span class="token punctuation">)</span><span aria-hidden="true" class="line-numbers-rows"><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span></span></code></pre></li>
<li><p>检索字段名并绛序只允许显示3条</p>
<pre class="line-numbers language-sql" data-language="sql"><code class="language-sql">mysql<span class="token operator">></span> <span class="token keyword">select</span> name <span class="token punctuation">,</span>age <span class="token keyword">from</span> student <span class="token keyword">order</span> <span class="token keyword">by</span> age <span class="token keyword">desc</span> <span class="token keyword">limit</span> <span class="token number">1</span><span class="token punctuation">;</span>
<span class="token operator">+</span><span class="token comment">------+-----+</span>
<span class="token operator">|</span> name <span class="token operator">|</span> age <span class="token operator">|</span>
<span class="token operator">+</span><span class="token comment">------+-----+</span>
<span class="token operator">|</span> 关羽 <span class="token operator">|</span> <span class="token number">21</span>  <span class="token operator">|</span>
<span class="token operator">+</span><span class="token comment">------+-----+</span>
<span class="token number">1</span> <span class="token keyword">row</span> <span class="token operator">in</span> <span class="token keyword">set</span> <span class="token punctuation">(</span><span class="token number">0.00</span> sec<span class="token punctuation">)</span><span aria-hidden="true" class="line-numbers-rows"><span></span><span></span><span></span><span></span><span></span><span></span><span></span></span></code></pre></li>
<li><p>检索案例表里条件age字段为21或24的所有内容按age升序排列</p>
<pre class="line-numbers language-sql" data-language="sql"><code class="language-sql">mysql<span class="token operator">></span> <span class="token keyword">select</span> name<span class="token punctuation">,</span>age<span class="token punctuation">,</span>address <span class="token keyword">from</span> student <span class="token keyword">where</span> age<span class="token operator">=</span><span class="token string">'21'</span><span class="token operator">or</span> age<span class="token operator">=</span><span class="token string">'18'</span> <span class="token keyword">order</span> <span class="token keyword">by</span> age<span class="token punctuation">;</span>
<span class="token operator">+</span><span class="token comment">------+-----+---------+</span>
<span class="token operator">|</span> name <span class="token operator">|</span> age <span class="token operator">|</span> address <span class="token operator">|</span>
<span class="token operator">+</span><span class="token comment">------+-----+---------+</span>
<span class="token operator">|</span> 张飞 <span class="token operator">|</span> <span class="token number">18</span>  <span class="token operator">|</span> 武汉    <span class="token operator">|</span>
<span class="token operator">|</span> 赵云 <span class="token operator">|</span> <span class="token number">18</span>  <span class="token operator">|</span> 咸宁    <span class="token operator">|</span>
<span class="token operator">|</span> 关羽 <span class="token operator">|</span> <span class="token number">21</span>  <span class="token operator">|</span> 宜昌    <span class="token operator">|</span>
<span class="token operator">+</span><span class="token comment">------+-----+---------+</span>
<span class="token number">3</span> <span class="token keyword">rows</span> <span class="token operator">in</span> <span class="token keyword">set</span> <span class="token punctuation">(</span><span class="token number">0.00</span> sec<span class="token punctuation">)</span>
<span aria-hidden="true" class="line-numbers-rows"><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span></span></code></pre></li>
<li><p>检索案例表中address为咸宁和孝感，并且年龄小于等于19的所有信息并按年龄升序排列</p>
<pre class="line-numbers language-sql" data-language="sql"><code class="language-sql">mysql<span class="token operator">></span> <span class="token keyword">select</span> <span class="token operator">*</span> <span class="token keyword">from</span> student <span class="token keyword">where</span> <span class="token punctuation">(</span>address<span class="token operator">=</span><span class="token string">'咸宁'</span> <span class="token operator">or</span> address<span class="token operator">=</span><span class="token string">'孝感'</span><span class="token punctuation">)</span> <span class="token operator">and</span> age <span class="token operator">&lt;=</span> <span class="token string">'19'</span> <span class="token keyword">order</span> <span class="token keyword">by</span> age<span class="token punctuation">;</span>
<span class="token operator">+</span><span class="token comment">----+------+---------+-------------+-----+------------+</span>
<span class="token operator">|</span> id <span class="token operator">|</span> name <span class="token operator">|</span> address <span class="token operator">|</span> phone       <span class="token operator">|</span> age <span class="token operator">|</span> birthday   <span class="token operator">|</span>
<span class="token operator">+</span><span class="token comment">----+------+---------+-------------+-----+------------+</span>
<span class="token operator">|</span>  <span class="token number">3</span> <span class="token operator">|</span> 赵云 <span class="token operator">|</span> 咸宁    <span class="token operator">|</span> <span class="token number">12345678912</span> <span class="token operator">|</span> <span class="token number">18</span>  <span class="token operator">|</span> <span class="token number">1998</span><span class="token operator">-</span><span class="token number">01</span><span class="token operator">-</span><span class="token number">21</span> <span class="token operator">|</span>
<span class="token operator">|</span>  <span class="token number">6</span> <span class="token operator">|</span> 赵云 <span class="token operator">|</span> 咸宁    <span class="token operator">|</span> <span class="token number">12345678912</span> <span class="token operator">|</span> <span class="token number">18</span>  <span class="token operator">|</span> <span class="token number">1998</span><span class="token operator">-</span><span class="token number">01</span><span class="token operator">-</span><span class="token number">21</span> <span class="token operator">|</span>
<span class="token operator">|</span>  <span class="token number">4</span> <span class="token operator">|</span> 刘备 <span class="token operator">|</span> 孝感    <span class="token operator">|</span> <span class="token number">15915915912</span> <span class="token operator">|</span> <span class="token number">19</span>  <span class="token operator">|</span> <span class="token number">1997</span><span class="token operator">-</span><span class="token number">09</span><span class="token operator">-</span><span class="token number">07</span> <span class="token operator">|</span>
<span class="token operator">|</span>  <span class="token number">5</span> <span class="token operator">|</span> 刘备 <span class="token operator">|</span> 孝感    <span class="token operator">|</span> <span class="token number">15915915912</span> <span class="token operator">|</span> <span class="token number">19</span>  <span class="token operator">|</span> <span class="token number">1997</span><span class="token operator">-</span><span class="token number">09</span><span class="token operator">-</span><span class="token number">07</span> <span class="token operator">|</span>
<span class="token operator">+</span><span class="token comment">----+------+---------+-------------+-----+------------+</span>
<span class="token number">4</span> <span class="token keyword">rows</span> <span class="token operator">in</span> <span class="token keyword">set</span> <span class="token punctuation">(</span><span class="token number">0.01</span> sec<span class="token punctuation">)</span><span aria-hidden="true" class="line-numbers-rows"><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span></span></code></pre></li>
<li><p>检索案例表里条件age字段不是21和23的name,age,address信息</p>
<pre class="line-numbers language-sql" data-language="sql"><code class="language-sql">mysql<span class="token operator">></span> <span class="token keyword">select</span> name<span class="token punctuation">,</span>address<span class="token punctuation">,</span>age <span class="token keyword">from</span> student <span class="token keyword">where</span> age <span class="token operator">not</span> <span class="token operator">in</span> <span class="token punctuation">(</span><span class="token string">'18'</span><span class="token punctuation">,</span><span class="token string">'19'</span><span class="token punctuation">)</span>
    <span class="token operator">-</span><span class="token operator">></span> <span class="token punctuation">;</span>
<span class="token operator">+</span><span class="token comment">------+---------+-----+</span>
<span class="token operator">|</span> name <span class="token operator">|</span> address <span class="token operator">|</span> age <span class="token operator">|</span>
<span class="token operator">+</span><span class="token comment">------+---------+-----+</span>
<span class="token operator">|</span> 关羽 <span class="token operator">|</span> 宜昌    <span class="token operator">|</span> <span class="token number">21</span>  <span class="token operator">|</span>
<span class="token operator">+</span><span class="token comment">------+---------+-----+</span>
<span class="token number">1</span> <span class="token keyword">row</span> <span class="token operator">in</span> <span class="token keyword">set</span> <span class="token punctuation">(</span><span class="token number">0.00</span> sec<span class="token punctuation">)</span><span aria-hidden="true" class="line-numbers-rows"><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span></span></code></pre></li>
<li><p>检索案例条件birthday字段为’1997-09-01’和’2000-01-01’的name,birthday的内容按升序排列</p>
<pre class="line-numbers language-sql" data-language="sql"><code class="language-sql">mysql<span class="token operator">></span> <span class="token keyword">select</span> name<span class="token punctuation">,</span>address<span class="token punctuation">,</span>birthday <span class="token keyword">from</span> student <span class="token keyword">where</span> birthday <span class="token operator">between</span> <span class="token string">'1997-09-01'</span> <span class="token operator">and</span> <span class="token string">'2000-01-01'</span> <span class="token keyword">order</span> <span class="token keyword">by</span> birthday<span class="token punctuation">;</span>
<span class="token operator">+</span><span class="token comment">------+---------+------------+</span>
<span class="token operator">|</span> name <span class="token operator">|</span> address <span class="token operator">|</span> birthday   <span class="token operator">|</span>
<span class="token operator">+</span><span class="token comment">------+---------+------------+</span>
<span class="token operator">|</span> 刘备 <span class="token operator">|</span> 孝感    <span class="token operator">|</span> <span class="token number">1997</span><span class="token operator">-</span><span class="token number">09</span><span class="token operator">-</span><span class="token number">07</span> <span class="token operator">|</span>
<span class="token operator">|</span> 刘备 <span class="token operator">|</span> 孝感    <span class="token operator">|</span> <span class="token number">1997</span><span class="token operator">-</span><span class="token number">09</span><span class="token operator">-</span><span class="token number">07</span> <span class="token operator">|</span>
<span class="token operator">|</span> 赵云 <span class="token operator">|</span> 咸宁    <span class="token operator">|</span> <span class="token number">1998</span><span class="token operator">-</span><span class="token number">01</span><span class="token operator">-</span><span class="token number">21</span> <span class="token operator">|</span>
<span class="token operator">|</span> 赵云 <span class="token operator">|</span> 咸宁    <span class="token operator">|</span> <span class="token number">1998</span><span class="token operator">-</span><span class="token number">01</span><span class="token operator">-</span><span class="token number">21</span> <span class="token operator">|</span>
<span class="token operator">|</span> 张飞 <span class="token operator">|</span> 武汉    <span class="token operator">|</span> <span class="token number">1998</span><span class="token operator">-</span><span class="token number">07</span><span class="token operator">-</span><span class="token number">01</span> <span class="token operator">|</span>
<span class="token operator">+</span><span class="token comment">------+---------+------------+</span>
<span class="token number">5</span> <span class="token keyword">rows</span> <span class="token operator">in</span> <span class="token keyword">set</span> <span class="token punctuation">(</span><span class="token number">0.00</span> sec<span class="token punctuation">)</span><span aria-hidden="true" class="line-numbers-rows"><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span></span></code></pre></li>
<li><p>检索案例age不等于19的所有信息并案绛序排列</p>
<pre class="line-numbers language-sql" data-language="sql"><code class="language-sql">mysql<span class="token operator">></span> <span class="token keyword">select</span> name<span class="token punctuation">,</span>address<span class="token punctuation">,</span>age <span class="token keyword">from</span> student <span class="token keyword">where</span> age<span class="token operator">!=</span><span class="token string">'19'</span> <span class="token keyword">order</span> <span class="token keyword">by</span> age <span class="token keyword">desc</span><span class="token punctuation">;</span>
<span class="token operator">+</span><span class="token comment">------+---------+-----+</span>
<span class="token operator">|</span> name <span class="token operator">|</span> address <span class="token operator">|</span> age <span class="token operator">|</span>
<span class="token operator">+</span><span class="token comment">------+---------+-----+</span>
<span class="token operator">|</span> 关羽 <span class="token operator">|</span> 宜昌    <span class="token operator">|</span> <span class="token number">21</span>  <span class="token operator">|</span>
<span class="token operator">|</span> 张飞 <span class="token operator">|</span> 武汉    <span class="token operator">|</span> <span class="token number">18</span>  <span class="token operator">|</span>
<span class="token operator">|</span> 赵云 <span class="token operator">|</span> 咸宁    <span class="token operator">|</span> <span class="token number">18</span>  <span class="token operator">|</span>
<span class="token operator">|</span> 赵云 <span class="token operator">|</span> 咸宁    <span class="token operator">|</span> <span class="token number">18</span>  <span class="token operator">|</span>
<span class="token operator">+</span><span class="token comment">------+---------+-----+</span><span aria-hidden="true" class="line-numbers-rows"><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span></span></code></pre></li>
<li><p>模糊查询：检索案例表里搜索条件name字段为张…的所有内容</p>
<pre class="line-numbers language-sql" data-language="sql"><code class="language-sql"><span class="token comment">/*两种方法*/</span>
mysql<span class="token operator">></span> <span class="token keyword">select</span> <span class="token operator">*</span> <span class="token keyword">from</span> student <span class="token keyword">where</span> name <span class="token operator">like</span> <span class="token string">'张%'</span><span class="token punctuation">;</span>
<span class="token operator">+</span><span class="token comment">----+------+---------+-------------+-----+------------+</span>
<span class="token operator">|</span> id <span class="token operator">|</span> name <span class="token operator">|</span> address <span class="token operator">|</span> phone       <span class="token operator">|</span> age <span class="token operator">|</span> birthday   <span class="token operator">|</span>
<span class="token operator">+</span><span class="token comment">----+------+---------+-------------+-----+------------+</span>
<span class="token operator">|</span>  <span class="token number">1</span> <span class="token operator">|</span> 张飞 <span class="token operator">|</span> 武汉    <span class="token operator">|</span> <span class="token number">13121312131</span> <span class="token operator">|</span> <span class="token number">18</span>  <span class="token operator">|</span> <span class="token number">1998</span><span class="token operator">-</span><span class="token number">07</span><span class="token operator">-</span><span class="token number">01</span> <span class="token operator">|</span>
<span class="token operator">+</span><span class="token comment">----+------+---------+-------------+-----+------------+</span>
<span class="token number">1</span> <span class="token keyword">row</span> <span class="token operator">in</span> <span class="token keyword">set</span> <span class="token punctuation">(</span><span class="token number">0.00</span> sec<span class="token punctuation">)</span>

mysql<span class="token operator">></span> <span class="token keyword">select</span> <span class="token operator">*</span> <span class="token keyword">from</span> student <span class="token keyword">where</span> name <span class="token operator">like</span> <span class="token string">'张_'</span><span class="token punctuation">;</span>
<span class="token operator">+</span><span class="token comment">----+------+---------+-------------+-----+------------+</span>
<span class="token operator">|</span> id <span class="token operator">|</span> name <span class="token operator">|</span> address <span class="token operator">|</span> phone       <span class="token operator">|</span> age <span class="token operator">|</span> birthday   <span class="token operator">|</span>
<span class="token operator">+</span><span class="token comment">----+------+---------+-------------+-----+------------+</span>
<span class="token operator">|</span>  <span class="token number">1</span> <span class="token operator">|</span> 张飞 <span class="token operator">|</span> 武汉    <span class="token operator">|</span> <span class="token number">13121312131</span> <span class="token operator">|</span> <span class="token number">18</span>  <span class="token operator">|</span> <span class="token number">1998</span><span class="token operator">-</span><span class="token number">07</span><span class="token operator">-</span><span class="token number">01</span> <span class="token operator">|</span>
<span class="token operator">+</span><span class="token comment">----+------+---------+-------------+-----+------------+</span>
<span class="token number">1</span> <span class="token keyword">row</span> <span class="token operator">in</span> <span class="token keyword">set</span> <span class="token punctuation">(</span><span class="token number">0.00</span> sec<span class="token punctuation">)</span><span aria-hidden="true" class="line-numbers-rows"><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span></span></code></pre></li>
<li><p>检索案例从表里搜索name字段为…云…的所有信息</p>
<pre class="line-numbers language-sql" data-language="sql"><code class="language-sql"><span class="token comment">/*同上，有两种方法*/</span>
mysql<span class="token operator">></span> <span class="token keyword">select</span> <span class="token operator">*</span> <span class="token keyword">from</span> student <span class="token keyword">where</span> name <span class="token operator">like</span> <span class="token string">'%云%'</span> <span class="token punctuation">;</span>
<span class="token operator">+</span><span class="token comment">----+------+---------+-------------+-----+------------+</span>
<span class="token operator">|</span> id <span class="token operator">|</span> name <span class="token operator">|</span> address <span class="token operator">|</span> phone       <span class="token operator">|</span> age <span class="token operator">|</span> birthday   <span class="token operator">|</span>
<span class="token operator">+</span><span class="token comment">----+------+---------+-------------+-----+------------+</span>
<span class="token operator">|</span>  <span class="token number">3</span> <span class="token operator">|</span> 赵云 <span class="token operator">|</span> 咸宁    <span class="token operator">|</span> <span class="token number">12345678912</span> <span class="token operator">|</span> <span class="token number">18</span>  <span class="token operator">|</span> <span class="token number">1998</span><span class="token operator">-</span><span class="token number">01</span><span class="token operator">-</span><span class="token number">21</span> <span class="token operator">|</span>
<span class="token operator">|</span>  <span class="token number">6</span> <span class="token operator">|</span> 赵云 <span class="token operator">|</span> 咸宁    <span class="token operator">|</span> <span class="token number">12345678912</span> <span class="token operator">|</span> <span class="token number">18</span>  <span class="token operator">|</span> <span class="token number">1998</span><span class="token operator">-</span><span class="token number">01</span><span class="token operator">-</span><span class="token number">21</span> <span class="token operator">|</span>
<span class="token operator">+</span><span class="token comment">----+------+---------+-------------+-----+------------+</span>
<span class="token number">2</span> <span class="token keyword">rows</span> <span class="token operator">in</span> <span class="token keyword">set</span> <span class="token punctuation">(</span><span class="token number">0.00</span> sec<span class="token punctuation">)</span><span aria-hidden="true" class="line-numbers-rows"><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span></span></code></pre></li>
<li><p>检索案例表里email字段带有…qq.com的显示name,email所有内容</p>
<pre class="line-numbers language-sql" data-language="sql"><code class="language-sql">mysql<span class="token operator">></span> <span class="token keyword">select</span> name<span class="token punctuation">,</span>email <span class="token keyword">from</span> student <span class="token keyword">where</span> email <span class="token operator">regexp</span><span class="token string">'qq.com$'</span><span class="token punctuation">;</span>
<span class="token operator">+</span><span class="token comment">------+--------------+</span>
<span class="token operator">|</span> name <span class="token operator">|</span> email        <span class="token operator">|</span>
<span class="token operator">+</span><span class="token comment">------+--------------+</span>
<span class="token operator">|</span> 张飞 <span class="token operator">|</span> <span class="token number">15465</span><span class="token variable">@qq.com</span> <span class="token operator">|</span>
<span class="token operator">|</span> 关羽 <span class="token operator">|</span> <span class="token number">4564</span><span class="token variable">@qq.com</span>  <span class="token operator">|</span>
<span class="token operator">+</span><span class="token comment">------+--------------+</span>
<span class="token number">2</span> <span class="token keyword">rows</span> <span class="token operator">in</span> <span class="token keyword">set</span> <span class="token punctuation">(</span><span class="token number">0.00</span> sec<span class="token punctuation">)</span><span aria-hidden="true" class="line-numbers-rows"><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span></span></code></pre></li>
<li><p>检索案例表里email字段除了…qq.com的所有内容</p>
<pre class="line-numbers language-sql" data-language="sql"><code class="language-sql"><span class="token comment">/*两种方法*/</span>
mysql<span class="token operator">></span> <span class="token keyword">select</span> <span class="token operator">*</span> <span class="token keyword">from</span> student <span class="token keyword">where</span> email <span class="token operator">regexp</span> <span class="token string">'\w*[^qq$].com'</span><span class="token punctuation">;</span>
<span class="token operator">+</span><span class="token comment">----+------+---------+-------------+-----+------------+-----------+</span>
<span class="token operator">|</span> id <span class="token operator">|</span> name <span class="token operator">|</span> address <span class="token operator">|</span> phone       <span class="token operator">|</span> age <span class="token operator">|</span> birthday   <span class="token operator">|</span> email     <span class="token operator">|</span>
<span class="token operator">+</span><span class="token comment">----+------+---------+-------------+-----+------------+-----------+</span>
<span class="token operator">|</span>  <span class="token number">3</span> <span class="token operator">|</span> 赵云 <span class="token operator">|</span> 咸宁    <span class="token operator">|</span> <span class="token number">12345678912</span> <span class="token operator">|</span> <span class="token number">18</span>  <span class="token operator">|</span> <span class="token number">1998</span><span class="token operator">-</span><span class="token number">01</span><span class="token operator">-</span><span class="token number">21</span> <span class="token operator">|</span> <span class="token number">4564</span><span class="token variable">@.com</span> <span class="token operator">|</span>
<span class="token operator">|</span>  <span class="token number">4</span> <span class="token operator">|</span> 刘备 <span class="token operator">|</span> 孝感    <span class="token operator">|</span> <span class="token number">15915915912</span> <span class="token operator">|</span> <span class="token number">19</span>  <span class="token operator">|</span> <span class="token number">1997</span><span class="token operator">-</span><span class="token number">09</span><span class="token operator">-</span><span class="token number">07</span> <span class="token operator">|</span> <span class="token number">4888</span><span class="token variable">@.com</span> <span class="token operator">|</span>
<span class="token operator">|</span>  <span class="token number">5</span> <span class="token operator">|</span> 刘备 <span class="token operator">|</span> 孝感    <span class="token operator">|</span> <span class="token number">15915915912</span> <span class="token operator">|</span> <span class="token number">19</span>  <span class="token operator">|</span> <span class="token number">1997</span><span class="token operator">-</span><span class="token number">09</span><span class="token operator">-</span><span class="token number">07</span> <span class="token operator">|</span> <span class="token number">4999</span><span class="token variable">@.com</span> <span class="token operator">|</span>
<span class="token operator">|</span>  <span class="token number">6</span> <span class="token operator">|</span> 赵云 <span class="token operator">|</span> 咸宁    <span class="token operator">|</span> <span class="token number">12345678912</span> <span class="token operator">|</span> <span class="token number">18</span>  <span class="token operator">|</span> <span class="token number">1998</span><span class="token operator">-</span><span class="token number">01</span><span class="token operator">-</span><span class="token number">21</span> <span class="token operator">|</span> <span class="token number">4000</span><span class="token variable">@.com</span> <span class="token operator">|</span>
<span class="token operator">+</span><span class="token comment">----+------+---------+-------------+-----+------------+-----------+</span>
<span class="token number">4</span> <span class="token keyword">rows</span> <span class="token operator">in</span> <span class="token keyword">set</span> <span class="token punctuation">(</span><span class="token number">0.00</span> sec<span class="token punctuation">)</span>

mysql<span class="token operator">></span> <span class="token keyword">select</span> <span class="token operator">*</span> <span class="token keyword">from</span> student <span class="token keyword">where</span> email <span class="token operator">regexp</span><span class="token string">'.*[^qq$].com'</span><span class="token punctuation">;</span>
<span class="token operator">+</span><span class="token comment">----+------+---------+-------------+-----+------------+-----------+</span>
<span class="token operator">|</span> id <span class="token operator">|</span> name <span class="token operator">|</span> address <span class="token operator">|</span> phone       <span class="token operator">|</span> age <span class="token operator">|</span> birthday   <span class="token operator">|</span> email     <span class="token operator">|</span>
<span class="token operator">+</span><span class="token comment">----+------+---------+-------------+-----+------------+-----------+</span>
<span class="token operator">|</span>  <span class="token number">3</span> <span class="token operator">|</span> 赵云 <span class="token operator">|</span> 咸宁    <span class="token operator">|</span> <span class="token number">12345678912</span> <span class="token operator">|</span> <span class="token number">18</span>  <span class="token operator">|</span> <span class="token number">1998</span><span class="token operator">-</span><span class="token number">01</span><span class="token operator">-</span><span class="token number">21</span> <span class="token operator">|</span> <span class="token number">4564</span><span class="token variable">@.com</span> <span class="token operator">|</span>
<span class="token operator">|</span>  <span class="token number">4</span> <span class="token operator">|</span> 刘备 <span class="token operator">|</span> 孝感    <span class="token operator">|</span> <span class="token number">15915915912</span> <span class="token operator">|</span> <span class="token number">19</span>  <span class="token operator">|</span> <span class="token number">1997</span><span class="token operator">-</span><span class="token number">09</span><span class="token operator">-</span><span class="token number">07</span> <span class="token operator">|</span> <span class="token number">4888</span><span class="token variable">@.com</span> <span class="token operator">|</span>
<span class="token operator">|</span>  <span class="token number">5</span> <span class="token operator">|</span> 刘备 <span class="token operator">|</span> 孝感    <span class="token operator">|</span> <span class="token number">15915915912</span> <span class="token operator">|</span> <span class="token number">19</span>  <span class="token operator">|</span> <span class="token number">1997</span><span class="token operator">-</span><span class="token number">09</span><span class="token operator">-</span><span class="token number">07</span> <span class="token operator">|</span> <span class="token number">4999</span><span class="token variable">@.com</span> <span class="token operator">|</span>
<span class="token operator">|</span>  <span class="token number">6</span> <span class="token operator">|</span> 赵云 <span class="token operator">|</span> 咸宁    <span class="token operator">|</span> <span class="token number">12345678912</span> <span class="token operator">|</span> <span class="token number">18</span>  <span class="token operator">|</span> <span class="token number">1998</span><span class="token operator">-</span><span class="token number">01</span><span class="token operator">-</span><span class="token number">21</span> <span class="token operator">|</span> <span class="token number">4000</span><span class="token variable">@.com</span> <span class="token operator">|</span>
<span class="token operator">+</span><span class="token comment">----+------+---------+-------------+-----+------------+-----------+</span>
<span class="token number">4</span> <span class="token keyword">rows</span> <span class="token operator">in</span> <span class="token keyword">set</span> <span class="token punctuation">(</span><span class="token number">0.00</span> sec<span class="token punctuation">)</span>
<span aria-hidden="true" class="line-numbers-rows"><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span></span></code></pre></li>
<li><p>检索案例表中总人数，最小年龄，最大年龄，年龄总和，平均值并起别名；</p>
<pre class="line-numbers language-sql" data-language="sql"><code class="language-sql">mysql<span class="token operator">></span> <span class="token keyword">select</span> <span class="token function">count</span><span class="token punctuation">(</span><span class="token operator">*</span><span class="token punctuation">)</span> <span class="token keyword">as</span> 总人数<span class="token punctuation">,</span><span class="token function">min</span><span class="token punctuation">(</span>age<span class="token punctuation">)</span> <span class="token keyword">as</span> 最小年龄<span class="token punctuation">,</span><span class="token function">sum</span><span class="token punctuation">(</span>age<span class="token punctuation">)</span> <span class="token keyword">as</span> 总和<span class="token punctuation">,</span><span class="token function">avg</span><span class="token punctuation">(</span>age<span class="token punctuation">)</span> <span class="token keyword">as</span> 平均值 <span class="token keyword">from</span> student<span class="token punctuation">;</span>
<span class="token operator">+</span><span class="token comment">--------+----------+------+--------------------+</span>
<span class="token operator">|</span> 总人数 <span class="token operator">|</span> 最小年龄 <span class="token operator">|</span> 总和 <span class="token operator">|</span> 平均值             <span class="token operator">|</span>
<span class="token operator">+</span><span class="token comment">--------+----------+------+--------------------+</span>
<span class="token operator">|</span>      <span class="token number">6</span> <span class="token operator">|</span> <span class="token number">18</span>       <span class="token operator">|</span>  <span class="token number">113</span> <span class="token operator">|</span> <span class="token number">18.833333333333332</span> <span class="token operator">|</span>
<span class="token operator">+</span><span class="token comment">--------+----------+------+--------------------+</span>
<span class="token number">1</span> <span class="token keyword">row</span> <span class="token operator">in</span> <span class="token keyword">set</span> <span class="token punctuation">(</span><span class="token number">0.01</span> sec<span class="token punctuation">)</span>
<span aria-hidden="true" class="line-numbers-rows"><span></span><span></span><span></span><span></span><span></span><span></span><span></span></span></code></pre></li>
<li><p>检索表里age年龄最大的，并只显示一位的信息；</p>
<pre class="line-numbers language-sql" data-language="sql"><code class="language-sql">mysql<span class="token operator">></span> <span class="token keyword">select</span> <span class="token operator">*</span> <span class="token keyword">from</span> student <span class="token keyword">order</span> <span class="token keyword">by</span> age <span class="token keyword">desc</span> <span class="token keyword">limit</span> <span class="token number">1</span><span class="token punctuation">;</span>
<span class="token operator">+</span><span class="token comment">----+------+---------+-------+-----+------------+-------------+</span>
<span class="token operator">|</span> id <span class="token operator">|</span> name <span class="token operator">|</span> address <span class="token operator">|</span> phone <span class="token operator">|</span> age <span class="token operator">|</span> birthday   <span class="token operator">|</span> email       <span class="token operator">|</span>
<span class="token operator">+</span><span class="token comment">----+------+---------+-------+-----+------------+------------	-+</span>
<span class="token operator">|</span>  <span class="token number">2</span> <span class="token operator">|</span> 关羽 <span class="token operator">|</span> 宜昌    <span class="token operator">|</span>       <span class="token operator">|</span> <span class="token number">21</span>  <span class="token operator">|</span> <span class="token number">1996</span><span class="token operator">-</span><span class="token number">07</span><span class="token operator">-</span><span class="token number">01</span> <span class="token operator">|</span> <span class="token number">4564</span><span class="token variable">@qq.com</span> <span class="token operator">|</span>
<span class="token operator">+</span><span class="token comment">----+------+---------+-------+-----+------------+-------------+</span>
<span class="token number">1</span> <span class="token keyword">row</span> <span class="token operator">in</span> <span class="token keyword">set</span> <span class="token punctuation">(</span><span class="token number">0.00</span> sec<span class="token punctuation">)</span><span aria-hidden="true" class="line-numbers-rows"><span></span><span></span><span></span><span></span><span></span><span></span><span></span></span></code></pre></li>
<li><p>时间处理的相关函数</p>
<pre class="line-numbers language-sql" data-language="sql"><code class="language-sql">mysql<span class="token operator">></span> <span class="token keyword">select</span> curtime<span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token operator">+</span><span class="token comment">-----------+</span>
<span class="token operator">|</span> curtime<span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token operator">|</span>
<span class="token operator">+</span><span class="token comment">-----------+</span>
<span class="token operator">|</span> <span class="token number">17</span>:<span class="token number">02</span>:<span class="token number">51</span>  <span class="token operator">|</span>
<span class="token operator">+</span><span class="token comment">-----------+</span>
<span class="token number">1</span> <span class="token keyword">row</span> <span class="token operator">in</span> <span class="token keyword">set</span> <span class="token punctuation">(</span><span class="token number">0.01</span> sec<span class="token punctuation">)</span>

mysql<span class="token operator">></span> <span class="token keyword">select</span> curtime<span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token operator">+</span><span class="token comment">-----------+</span>
<span class="token operator">|</span> curtime<span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token operator">|</span>
<span class="token operator">+</span><span class="token comment">-----------+</span>
<span class="token operator">|</span> <span class="token number">17</span>:<span class="token number">02</span>:<span class="token number">53</span>  <span class="token operator">|</span>
<span class="token operator">+</span><span class="token comment">-----------+</span>
<span class="token number">1</span> <span class="token keyword">row</span> <span class="token operator">in</span> <span class="token keyword">set</span> <span class="token punctuation">(</span><span class="token number">0.00</span> sec<span class="token punctuation">)</span>

mysql<span class="token operator">></span> <span class="token keyword">select</span> curtime<span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token operator">+</span><span class="token comment">-----------+</span>
<span class="token operator">|</span> curtime<span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token operator">|</span>
<span class="token operator">+</span><span class="token comment">-----------+</span>
<span class="token operator">|</span> <span class="token number">17</span>:<span class="token number">02</span>:<span class="token number">54</span>  <span class="token operator">|</span>
<span class="token operator">+</span><span class="token comment">-----------+</span>
<span class="token number">1</span> <span class="token keyword">row</span> <span class="token operator">in</span> <span class="token keyword">set</span> <span class="token punctuation">(</span><span class="token number">0.00</span> sec<span class="token punctuation">)</span>

mysql<span class="token operator">></span> <span class="token keyword">select</span> curtime<span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token operator">+</span><span class="token comment">-----------+</span>
<span class="token operator">|</span> curtime<span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token operator">|</span>
<span class="token operator">+</span><span class="token comment">-----------+</span>
<span class="token operator">|</span> <span class="token number">17</span>:<span class="token number">02</span>:<span class="token number">55</span>  <span class="token operator">|</span>
<span class="token operator">+</span><span class="token comment">-----------+</span>
<span class="token number">1</span> <span class="token keyword">row</span> <span class="token operator">in</span> <span class="token keyword">set</span> <span class="token punctuation">(</span><span class="token number">0.00</span> sec<span class="token punctuation">)</span>

mysql<span class="token operator">></span> <span class="token keyword">select</span> curdate<span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token operator">+</span><span class="token comment">------------+</span>
<span class="token operator">|</span> curdate<span class="token punctuation">(</span><span class="token punctuation">)</span>  <span class="token operator">|</span>
<span class="token operator">+</span><span class="token comment">------------+</span>
<span class="token operator">|</span> <span class="token number">2022</span><span class="token operator">-</span><span class="token number">01</span><span class="token operator">-</span><span class="token number">05</span> <span class="token operator">|</span>
<span class="token operator">+</span><span class="token comment">------------+</span>
<span class="token number">1</span> <span class="token keyword">row</span> <span class="token operator">in</span> <span class="token keyword">set</span> <span class="token punctuation">(</span><span class="token number">0.00</span> sec<span class="token punctuation">)</span>

mysql<span class="token operator">></span> <span class="token keyword">select</span> <span class="token keyword">month</span><span class="token punctuation">(</span><span class="token function">now</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token operator">+</span><span class="token comment">--------------+</span>
<span class="token operator">|</span> <span class="token keyword">month</span><span class="token punctuation">(</span><span class="token function">now</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span> <span class="token operator">|</span>
<span class="token operator">+</span><span class="token comment">--------------+</span>
<span class="token operator">|</span>            <span class="token number">1</span> <span class="token operator">|</span>
<span class="token operator">+</span><span class="token comment">--------------+</span>
<span class="token number">1</span> <span class="token keyword">row</span> <span class="token operator">in</span> <span class="token keyword">set</span> <span class="token punctuation">(</span><span class="token number">0.02</span> sec<span class="token punctuation">)</span>

mysql<span class="token operator">></span> <span class="token keyword">select</span> <span class="token function">now</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token operator">+</span><span class="token comment">---------------------+</span>
<span class="token operator">|</span> <span class="token function">now</span><span class="token punctuation">(</span><span class="token punctuation">)</span>               <span class="token operator">|</span>
<span class="token operator">+</span><span class="token comment">---------------------+</span>
<span class="token operator">|</span> <span class="token number">2022</span><span class="token operator">-</span><span class="token number">01</span><span class="token operator">-</span><span class="token number">05</span> <span class="token number">17</span>:<span class="token number">04</span>:<span class="token number">12</span> <span class="token operator">|</span>
<span class="token operator">+</span><span class="token comment">---------------------+</span>
<span class="token number">1</span> <span class="token keyword">row</span> <span class="token operator">in</span> <span class="token keyword">set</span> <span class="token punctuation">(</span><span class="token number">0.00</span> sec<span class="token punctuation">)</span>
<span aria-hidden="true" class="line-numbers-rows"><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span></span></code></pre></li>
<li><p>检索出生日是7月份的学生同学</p>
<pre class="line-numbers language-sql" data-language="sql"><code class="language-sql">mysql<span class="token operator">></span> <span class="token keyword">select</span> name<span class="token punctuation">,</span>birthday <span class="token keyword">from</span> student <span class="token keyword">where</span> <span class="token keyword">month</span><span class="token punctuation">(</span>birthday<span class="token punctuation">)</span><span class="token operator">=</span><span class="token number">7</span><span class="token punctuation">;</span>
<span class="token operator">+</span><span class="token comment">------+------------+</span>
<span class="token operator">|</span> name <span class="token operator">|</span> birthday   <span class="token operator">|</span>
<span class="token operator">+</span><span class="token comment">------+------------+</span>
<span class="token operator">|</span> 张飞 <span class="token operator">|</span> <span class="token number">1998</span><span class="token operator">-</span><span class="token number">07</span><span class="token operator">-</span><span class="token number">01</span> <span class="token operator">|</span>
<span class="token operator">|</span> 关羽 <span class="token operator">|</span> <span class="token number">1996</span><span class="token operator">-</span><span class="token number">07</span><span class="token operator">-</span><span class="token number">01</span> <span class="token operator">|</span>
<span class="token operator">+</span><span class="token comment">------+------------+</span>
<span class="token number">2</span> <span class="token keyword">rows</span> <span class="token operator">in</span> <span class="token keyword">set</span> <span class="token punctuation">(</span><span class="token number">0.00</span> sec<span class="token punctuation">)</span><span aria-hidden="true" class="line-numbers-rows"><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span></span></code></pre></li>
<li><p>检索出生日期在下半年的同学并按月份排序</p>
<pre class="line-numbers language-sql" data-language="sql"><code class="language-sql">mysql<span class="token operator">></span> <span class="token keyword">select</span> <span class="token operator">*</span> <span class="token keyword">from</span> student <span class="token keyword">where</span> <span class="token keyword">month</span><span class="token punctuation">(</span>birthday<span class="token punctuation">)</span><span class="token operator">>=</span><span class="token number">6</span> <span class="token operator">and</span> <span class="token keyword">month</span><span class="token punctuation">(</span>birthday<span class="token punctuation">)</span><span class="token operator">&lt;=</span><span class="token number">12</span> <span class="token keyword">order</span> <span class="token keyword">by</span> <span class="token keyword">month</span><span class="token punctuation">(</span>birthday<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token operator">+</span><span class="token comment">----+------+---------+-------------+-----+------------+--------------+</span>
<span class="token operator">|</span> id <span class="token operator">|</span> name <span class="token operator">|</span> address <span class="token operator">|</span> phone       <span class="token operator">|</span> age <span class="token operator">|</span> birthday   <span class="token operator">|</span> email        <span class="token operator">|</span>
<span class="token operator">+</span><span class="token comment">----+------+---------+-------------+-----+------------+--------------+</span>
<span class="token operator">|</span>  <span class="token number">1</span> <span class="token operator">|</span> 张飞 <span class="token operator">|</span> 武汉    <span class="token operator">|</span> <span class="token number">13121312131</span> <span class="token operator">|</span> <span class="token number">18</span>  <span class="token operator">|</span> <span class="token number">1998</span><span class="token operator">-</span><span class="token number">07</span><span class="token operator">-</span><span class="token number">01</span> <span class="token operator">|</span> <span class="token number">15465</span><span class="token variable">@qq.com</span> <span class="token operator">|</span>
<span class="token operator">|</span>  <span class="token number">2</span> <span class="token operator">|</span> 关羽 <span class="token operator">|</span> 宜昌    <span class="token operator">|</span>             <span class="token operator">|</span> <span class="token number">21</span>  <span class="token operator">|</span> <span class="token number">1996</span><span class="token operator">-</span><span class="token number">07</span><span class="token operator">-</span><span class="token number">01</span> <span class="token operator">|</span> <span class="token number">4564</span><span class="token variable">@qq.com</span>  <span class="token operator">|</span>
<span class="token operator">|</span>  <span class="token number">4</span> <span class="token operator">|</span> 刘备 <span class="token operator">|</span> 孝感    <span class="token operator">|</span> <span class="token number">15915915912</span> <span class="token operator">|</span> <span class="token number">19</span>  <span class="token operator">|</span> <span class="token number">1997</span><span class="token operator">-</span><span class="token number">09</span><span class="token operator">-</span><span class="token number">07</span> <span class="token operator">|</span> <span class="token number">4888</span><span class="token variable">@.com</span>    <span class="token operator">|</span>
<span class="token operator">|</span>  <span class="token number">5</span> <span class="token operator">|</span> 刘备 <span class="token operator">|</span> 孝感    <span class="token operator">|</span> <span class="token number">15915915912</span> <span class="token operator">|</span> <span class="token number">19</span>  <span class="token operator">|</span> <span class="token number">1997</span><span class="token operator">-</span><span class="token number">09</span><span class="token operator">-</span><span class="token number">07</span> <span class="token operator">|</span> <span class="token number">4999</span><span class="token variable">@.com</span>    <span class="token operator">|</span>
<span class="token operator">+</span><span class="token comment">----+------+---------+-------------+-----+------------+--------------+</span>
<span class="token number">4</span> <span class="token keyword">rows</span> <span class="token operator">in</span> <span class="token keyword">set</span> <span class="token punctuation">(</span><span class="token number">0.00</span> sec<span class="token punctuation">)</span><span aria-hidden="true" class="line-numbers-rows"><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span></span></code></pre></li>
<li><p>检索所有学生的姓</p>
<pre class="line-numbers language-sql" data-language="sql"><code class="language-sql">mysql<span class="token operator">></span> <span class="token keyword">select</span> <span class="token keyword">left</span><span class="token punctuation">(</span>name<span class="token punctuation">,</span><span class="token number">1</span><span class="token punctuation">)</span><span class="token punctuation">,</span>name <span class="token keyword">from</span> student<span class="token punctuation">;</span>
<span class="token operator">+</span><span class="token comment">--------------+------+</span>
<span class="token operator">|</span> <span class="token keyword">left</span><span class="token punctuation">(</span>name<span class="token punctuation">,</span><span class="token number">1</span><span class="token punctuation">)</span> <span class="token operator">|</span> name <span class="token operator">|</span>
<span class="token operator">+</span><span class="token comment">--------------+------+</span>
<span class="token operator">|</span> 张           <span class="token operator">|</span> 张飞 <span class="token operator">|</span>
<span class="token operator">|</span> 关           <span class="token operator">|</span> 关羽 <span class="token operator">|</span>
<span class="token operator">|</span> 赵           <span class="token operator">|</span> 赵云 <span class="token operator">|</span>
<span class="token operator">|</span> 刘           <span class="token operator">|</span> 刘备 <span class="token operator">|</span>
<span class="token operator">|</span> 刘           <span class="token operator">|</span> 刘备 <span class="token operator">|</span>
<span class="token operator">|</span> 赵           <span class="token operator">|</span> 赵云 <span class="token operator">|</span>
<span class="token operator">+</span><span class="token comment">--------------+------+</span>
<span class="token number">6</span> <span class="token keyword">rows</span> <span class="token operator">in</span> <span class="token keyword">set</span> <span class="token punctuation">(</span><span class="token number">0.02</span> sec<span class="token punctuation">)</span><span aria-hidden="true" class="line-numbers-rows"><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span></span></code></pre></li>
<li><p>检索年龄并去重</p>
<pre class="line-numbers language-sql" data-language="sql"><code class="language-sql">mysql<span class="token operator">></span> <span class="token keyword">select</span> <span class="token keyword">distinct</span><span class="token punctuation">(</span>age<span class="token punctuation">)</span> <span class="token keyword">from</span> student <span class="token keyword">order</span> <span class="token keyword">by</span> age<span class="token punctuation">;</span>
<span class="token operator">+</span><span class="token comment">-----+</span>
<span class="token operator">|</span> age <span class="token operator">|</span>
<span class="token operator">+</span><span class="token comment">-----+</span>
<span class="token operator">|</span> <span class="token number">18</span>  <span class="token operator">|</span>
<span class="token operator">|</span> <span class="token number">19</span>  <span class="token operator">|</span>
<span class="token operator">|</span> <span class="token number">21</span>  <span class="token operator">|</span>
<span class="token operator">+</span><span class="token comment">-----+</span>
<span class="token number">3</span> <span class="token keyword">rows</span> <span class="token operator">in</span> <span class="token keyword">set</span> <span class="token punctuation">(</span><span class="token number">0.00</span> sec<span class="token punctuation">)</span><span aria-hidden="true" class="line-numbers-rows"><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span></span></code></pre></li>
<li><p>检索表里年龄有几个并查看内容</p>
<pre class="line-numbers language-sql" data-language="sql"><code class="language-sql">mysql<span class="token operator">></span> <span class="token keyword">select</span> <span class="token function">count</span><span class="token punctuation">(</span>age<span class="token punctuation">)</span> <span class="token keyword">as</span> 年龄数<span class="token punctuation">,</span>age <span class="token keyword">from</span> student <span class="token keyword">group</span> <span class="token keyword">by</span> age <span class="token keyword">having</span> <span class="token function">max</span><span class="token punctuation">(</span>age<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token operator">+</span><span class="token comment">--------+-----+</span>
<span class="token operator">|</span> 年龄数 <span class="token operator">|</span> age <span class="token operator">|</span>
<span class="token operator">+</span><span class="token comment">--------+-----+</span>
<span class="token operator">|</span>      <span class="token number">3</span> <span class="token operator">|</span> <span class="token number">18</span>  <span class="token operator">|</span>
<span class="token operator">|</span>      <span class="token number">2</span> <span class="token operator">|</span> <span class="token number">19</span>  <span class="token operator">|</span>
<span class="token operator">|</span>      <span class="token number">1</span> <span class="token operator">|</span> <span class="token number">21</span>  <span class="token operator">|</span>
<span class="token operator">+</span><span class="token comment">--------+-----+</span>
<span class="token number">3</span> <span class="token keyword">rows</span> <span class="token operator">in</span> <span class="token keyword">set</span> <span class="token punctuation">(</span><span class="token number">0.00</span> sec<span class="token punctuation">)</span><span aria-hidden="true" class="line-numbers-rows"><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span></span></code></pre></li>
<li><p>检索表里年龄有几个年龄等于18并查看内容</p>
<pre class="line-numbers language-sql" data-language="sql"><code class="language-sql">mysql<span class="token operator">></span> <span class="token keyword">select</span> <span class="token function">count</span><span class="token punctuation">(</span>age<span class="token punctuation">)</span> <span class="token keyword">as</span> 年龄数<span class="token punctuation">,</span>age <span class="token keyword">from</span> student <span class="token keyword">group</span> <span class="token keyword">by</span> age <span class="token keyword">having</span> <span class="token function">max</span><span class="token punctuation">(</span>age<span class="token punctuation">)</span><span class="token operator">=</span><span class="token number">18</span><span class="token punctuation">;</span>
<span class="token operator">+</span><span class="token comment">--------+-----+</span>
<span class="token operator">|</span> 年龄数 <span class="token operator">|</span> age <span class="token operator">|</span>
<span class="token operator">+</span><span class="token comment">--------+-----+</span>
<span class="token operator">|</span>      <span class="token number">3</span> <span class="token operator">|</span> <span class="token number">18</span>  <span class="token operator">|</span>
<span class="token operator">+</span><span class="token comment">--------+-----+</span>
<span class="token number">1</span> <span class="token keyword">row</span> <span class="token operator">in</span> <span class="token keyword">set</span> <span class="token punctuation">(</span><span class="token number">0.00</span> sec<span class="token punctuation">)</span><span aria-hidden="true" class="line-numbers-rows"><span></span><span></span><span></span><span></span><span></span><span></span><span></span></span></code></pre>

<p>​</p>
</li>
</ul>
<h3 id="2-2、多表操作"><a href="#2-2、多表操作" class="headerlink" title="2.2、多表操作"></a>2.2、多表操作</h3> 
      <!-- reward -->
      
    </div>
    

    <!-- copyright -->
    
    <div class="declare">
      <ul class="post-copyright">
        <li>
          <i class="ri-copyright-line"></i>
          <strong>版权声明： </strong>
          
          本博客所有文章除特别声明外，著作权归作者所有。转载请注明出处！
          
        </li>
      </ul>
    </div>
    
    <footer class="article-footer">
       
<div class="share-btn">
      <span class="share-sns share-outer">
        <i class="ri-share-forward-line"></i>
        分享
      </span>
      <div class="share-wrap">
        <i class="arrow"></i>
        <div class="share-icons">
          
          <a class="weibo share-sns" href="javascript:;" data-type="weibo">
            <i class="ri-weibo-fill"></i>
          </a>
          <a class="weixin share-sns wxFab" href="javascript:;" data-type="weixin">
            <i class="ri-wechat-fill"></i>
          </a>
          <a class="qq share-sns" href="javascript:;" data-type="qq">
            <i class="ri-qq-fill"></i>
          </a>
          <a class="douban share-sns" href="javascript:;" data-type="douban">
            <i class="ri-douban-line"></i>
          </a>
          <!-- <a class="qzone share-sns" href="javascript:;" data-type="qzone">
            <i class="icon icon-qzone"></i>
          </a> -->
          
          <a class="facebook share-sns" href="javascript:;" data-type="facebook">
            <i class="ri-facebook-circle-fill"></i>
          </a>
          <a class="twitter share-sns" href="javascript:;" data-type="twitter">
            <i class="ri-twitter-fill"></i>
          </a>
          <a class="google share-sns" href="javascript:;" data-type="google">
            <i class="ri-google-fill"></i>
          </a>
        </div>
      </div>
</div>

<div class="wx-share-modal">
    <a class="modal-close" href="javascript:;"><i class="ri-close-circle-line"></i></a>
    <p>扫一扫，分享到微信</p>
    <div class="wx-qrcode">
      <img src="//api.qrserver.com/v1/create-qr-code/?size=150x150&data=http://www.harfe.icu/2022/03/06/mysql%E6%95%B0%E6%8D%AE%E5%BA%93/" alt="微信分享二维码">
    </div>
</div>

<div id="share-mask"></div>  
    </footer>
  </div>

   
  <nav class="article-nav">
    
      <a href="/2022/03/06/%E5%8F%8D%E5%B0%84%E6%9C%BA%E5%88%B6/" class="article-nav-link">
        <strong class="article-nav-caption">上一篇</strong>
        <div class="article-nav-title">
          
            反射机制
          
        </div>
      </a>
    
    
      <a href="/2022/03/06/mybatis%E7%AC%94%E8%AE%B0/" class="article-nav-link">
        <strong class="article-nav-caption">下一篇</strong>
        <div class="article-nav-title">mybatis</div>
      </a>
    
  </nav>

   
<!-- valine评论 -->
<div id="vcomments-box">
  <div id="vcomments"></div>
</div>
<script src="//cdn1.lncld.net/static/js/3.0.4/av-min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/valine@1.4.14/dist/Valine.min.js"></script>
<script>
  new Valine({
    el: "#vcomments",
    app_id: "naIjOvCa6fRj0wYNsOmHOipt-gzGzoHsz",
    app_key: "m6dupJxtpd3hiAmudK081SaM",
    path: window.location.pathname,
    avatar: "monsterid",
    placeholder: "给我的文章加点评论吧~",
    recordIP: true,
  });
  const infoEle = document.querySelector("#vcomments .info");
  if (infoEle && infoEle.childNodes && infoEle.childNodes.length > 0) {
    infoEle.childNodes.forEach(function (item) {
      item.parentNode.removeChild(item);
    });
  }
</script>
<style>
  #vcomments-box {
    padding: 5px 30px;
  }

  @media screen and (max-width: 800px) {
    #vcomments-box {
      padding: 5px 0px;
    }
  }

  #vcomments-box #vcomments {
    background-color: #fff;
  }

  .v .vlist .vcard .vh {
    padding-right: 20px;
  }

  .v .vlist .vcard {
    padding-left: 10px;
  }
</style>

 
   
     
</article>

</section>
      <footer class="footer">
  <div class="outer">
    <ul>
      <li>
        Copyrights &copy;
        2021-2022
        <i class="ri-heart-fill heart_icon"></i> zhenghangfei
      </li>
    </ul>
    <ul>
      <li>
        
      </li>
    </ul>
    <ul>
      <li>
        
        
        <span>
  <span><i class="ri-user-3-fill"></i>访问人数:<span id="busuanzi_value_site_uv"></span></span>
  <span class="division">|</span>
  <span><i class="ri-eye-fill"></i>浏览次数:<span id="busuanzi_value_page_pv"></span></span>
</span>
        
      </li>
    </ul>
    <ul>
      
    </ul>
    <ul>
      
      <li>
          <img src="/images/beian.png"></img>
          <a href="https://beian.miit.gov.cn/" target="_black" rel="nofollow">鄂ICP备2022003225号-1</a>
      </li>
        
    </ul>
    <ul>
      <li>
        <!-- cnzz统计 -->
        
        <script type="text/javascript" src='https://s9.cnzz.com/z_stat.php?id=1278069914&amp;web_id=1278069914'></script>
        
      </li>
    </ul>
  </div>
</footer>    
    </main>
    <div class="float_btns">
      <div class="totop" id="totop">
  <i class="ri-arrow-up-line"></i>
</div>

<div class="todark" id="todark">
  <i class="ri-moon-line"></i>
</div>

    </div>
    <aside class="sidebar on">
      <button class="navbar-toggle"></button>
<nav class="navbar">
  
  <div class="logo">
    <a href="/"><img src="/images/ayer-side.svg" alt="hangfei&#39;blog"></a>
  </div>
  
  <ul class="nav nav-main">
    
    <li class="nav-item">
      <a class="nav-item-link" href="/">主页</a>
    </li>
    
    <li class="nav-item">
      <a class="nav-item-link" href="/archives">归档</a>
    </li>
    
    <li class="nav-item">
      <a class="nav-item-link" href="/about">关于我</a>
    </li>
    
  </ul>
</nav>
<nav class="navbar navbar-bottom">
  <ul class="nav">
    <li class="nav-item">
      
      <a class="nav-item-link nav-item-search"  title="搜索">
        <i class="ri-search-line"></i>
      </a>
      
      
      <a class="nav-item-link" target="_blank" href="/atom.xml" title="RSS Feed">
        <i class="ri-rss-line"></i>
      </a>
      
    </li>
  </ul>
</nav>
<div class="search-form-wrap">
  <div class="local-search local-search-plugin">
  <input type="search" id="local-search-input" class="local-search-input" placeholder="Search...">
  <div id="local-search-result" class="local-search-result"></div>
</div>
</div>
    </aside>
    <div id="mask"></div>

<!-- #reward -->
<div id="reward">
  <span class="close"><i class="ri-close-line"></i></span>
  <p class="reward-p"><i class="ri-cup-line"></i>请我喝杯咖啡吧~</p>
  <div class="reward-box">
    
    <div class="reward-item">
      <img class="reward-img" src="/images/alipay.jpg">
      <span class="reward-type">支付宝</span>
    </div>
    
    
    <div class="reward-item">
      <img class="reward-img" src="/images/wechatpay.jpg">
      <span class="reward-type">微信</span>
    </div>
    
  </div>
</div>
    
<script src="/js/jquery-3.6.0.min.js"></script>
 
<script src="/js/lazyload.min.js"></script>

<!-- Tocbot -->
 
<script src="/js/tocbot.min.js"></script>

<script>
  tocbot.init({
    tocSelector: ".tocbot",
    contentSelector: ".article-entry",
    headingSelector: "h1, h2, h3, h4, h5, h6",
    hasInnerContainers: true,
    scrollSmooth: true,
    scrollContainer: "main",
    positionFixedSelector: ".tocbot",
    positionFixedClass: "is-position-fixed",
    fixedSidebarOffset: "auto",
  });
</script>

<script src="https://cdn.jsdelivr.net/npm/jquery-modal@0.9.2/jquery.modal.min.js"></script>
<link
  rel="stylesheet"
  href="https://cdn.jsdelivr.net/npm/jquery-modal@0.9.2/jquery.modal.min.css"
/>
<script src="https://cdn.jsdelivr.net/npm/justifiedGallery@3.7.0/dist/js/jquery.justifiedGallery.min.js"></script>

<script src="/dist/main.js"></script>

<!-- ImageViewer -->
 <!-- Root element of PhotoSwipe. Must have class pswp. -->
<div class="pswp" tabindex="-1" role="dialog" aria-hidden="true">

    <!-- Background of PhotoSwipe. 
         It's a separate element as animating opacity is faster than rgba(). -->
    <div class="pswp__bg"></div>

    <!-- Slides wrapper with overflow:hidden. -->
    <div class="pswp__scroll-wrap">

        <!-- Container that holds slides. 
            PhotoSwipe keeps only 3 of them in the DOM to save memory.
            Don't modify these 3 pswp__item elements, data is added later on. -->
        <div class="pswp__container">
            <div class="pswp__item"></div>
            <div class="pswp__item"></div>
            <div class="pswp__item"></div>
        </div>

        <!-- Default (PhotoSwipeUI_Default) interface on top of sliding area. Can be changed. -->
        <div class="pswp__ui pswp__ui--hidden">

            <div class="pswp__top-bar">

                <!--  Controls are self-explanatory. Order can be changed. -->

                <div class="pswp__counter"></div>

                <button class="pswp__button pswp__button--close" title="Close (Esc)"></button>

                <button class="pswp__button pswp__button--share" style="display:none" title="Share"></button>

                <button class="pswp__button pswp__button--fs" title="Toggle fullscreen"></button>

                <button class="pswp__button pswp__button--zoom" title="Zoom in/out"></button>

                <!-- Preloader demo http://codepen.io/dimsemenov/pen/yyBWoR -->
                <!-- element will get class pswp__preloader--active when preloader is running -->
                <div class="pswp__preloader">
                    <div class="pswp__preloader__icn">
                        <div class="pswp__preloader__cut">
                            <div class="pswp__preloader__donut"></div>
                        </div>
                    </div>
                </div>
            </div>

            <div class="pswp__share-modal pswp__share-modal--hidden pswp__single-tap">
                <div class="pswp__share-tooltip"></div>
            </div>

            <button class="pswp__button pswp__button--arrow--left" title="Previous (arrow left)">
            </button>

            <button class="pswp__button pswp__button--arrow--right" title="Next (arrow right)">
            </button>

            <div class="pswp__caption">
                <div class="pswp__caption__center"></div>
            </div>

        </div>

    </div>

</div>

<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/photoswipe@4.1.3/dist/photoswipe.min.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/photoswipe@4.1.3/dist/default-skin/default-skin.min.css">
<script src="https://cdn.jsdelivr.net/npm/photoswipe@4.1.3/dist/photoswipe.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/photoswipe@4.1.3/dist/photoswipe-ui-default.min.js"></script>

<script>
    function viewer_init() {
        let pswpElement = document.querySelectorAll('.pswp')[0];
        let $imgArr = document.querySelectorAll(('.article-entry img:not(.reward-img)'))

        $imgArr.forEach(($em, i) => {
            $em.onclick = () => {
                // slider展开状态
                // todo: 这样不好，后面改成状态
                if (document.querySelector('.left-col.show')) return
                let items = []
                $imgArr.forEach(($em2, i2) => {
                    let img = $em2.getAttribute('data-idx', i2)
                    let src = $em2.getAttribute('data-target') || $em2.getAttribute('src')
                    let title = $em2.getAttribute('alt')
                    // 获得原图尺寸
                    const image = new Image()
                    image.src = src
                    items.push({
                        src: src,
                        w: image.width || $em2.width,
                        h: image.height || $em2.height,
                        title: title
                    })
                })
                var gallery = new PhotoSwipe(pswpElement, PhotoSwipeUI_Default, items, {
                    index: parseInt(i)
                });
                gallery.init()
            }
        })
    }
    viewer_init()
</script> 
<!-- MathJax -->

<!-- Katex -->
 
    
        <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.11.1/dist/katex.min.css">
        <script src="https://cdn.jsdelivr.net/npm/katex@0.11.1/dist/katex.min.js"></script>
        <script src="https://cdn.jsdelivr.net/npm/katex@0.11.1/dist/contrib/auto-render.min.js"></script>
        
    
 
<!-- busuanzi  -->
 
<script src="/js/busuanzi-2.3.pure.min.js"></script>
 
<!-- ClickLove -->

<!-- ClickBoom1 -->

<!-- ClickBoom2 -->

<!-- CodeCopy -->
 
<link rel="stylesheet" href="/css/clipboard.css">
 <script src="https://cdn.jsdelivr.net/npm/clipboard@2/dist/clipboard.min.js"></script>
<script>
  function wait(callback, seconds) {
    var timelag = null;
    timelag = window.setTimeout(callback, seconds);
  }
  !function (e, t, a) {
    var initCopyCode = function(){
      var copyHtml = '';
      copyHtml += '<button class="btn-copy" data-clipboard-snippet="">';
      copyHtml += '<i class="ri-file-copy-2-line"></i><span>COPY</span>';
      copyHtml += '</button>';
      $(".highlight .code pre").before(copyHtml);
      $(".article pre code").before(copyHtml);
      var clipboard = new ClipboardJS('.btn-copy', {
        target: function(trigger) {
          return trigger.nextElementSibling;
        }
      });
      clipboard.on('success', function(e) {
        let $btn = $(e.trigger);
        $btn.addClass('copied');
        let $icon = $($btn.find('i'));
        $icon.removeClass('ri-file-copy-2-line');
        $icon.addClass('ri-checkbox-circle-line');
        let $span = $($btn.find('span'));
        $span[0].innerText = 'COPIED';
        
        wait(function () { // 等待两秒钟后恢复
          $icon.removeClass('ri-checkbox-circle-line');
          $icon.addClass('ri-file-copy-2-line');
          $span[0].innerText = 'COPY';
        }, 2000);
      });
      clipboard.on('error', function(e) {
        e.clearSelection();
        let $btn = $(e.trigger);
        $btn.addClass('copy-failed');
        let $icon = $($btn.find('i'));
        $icon.removeClass('ri-file-copy-2-line');
        $icon.addClass('ri-time-line');
        let $span = $($btn.find('span'));
        $span[0].innerText = 'COPY FAILED';
        
        wait(function () { // 等待两秒钟后恢复
          $icon.removeClass('ri-time-line');
          $icon.addClass('ri-file-copy-2-line');
          $span[0].innerText = 'COPY';
        }, 2000);
      });
    }
    initCopyCode();
  }(window, document);
</script>
 
<!-- CanvasBackground -->

<script>
  if (window.mermaid) {
    mermaid.initialize({ theme: "forest" });
  }
</script>


    
    <div id="music">
    
    
    
    <iframe frameborder="no" border="1" marginwidth="0" marginheight="0" width="200" height="52"
        src="//music.163.com/outchain/player?type=2&id=22707008&auto=1&height=32"></iframe>
</div>

<style>
    #music {
        position: fixed;
        right: 15px;
        bottom: 0;
        z-index: 998;
    }
</style>
    
    

  </div>
</body>

</html>